#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,string>>people(n);
    vector<pair<string,string>>name(n/2);
    for (int i=0;i<n;i++)
    {
        int p;
        string s;
        cin>>p>>s;
        people[i]=pair<int,string>(p,s);
    }
    for (int i=0;!people.empty();i++)
    {
        name[i].first=people[0].second;
        for (int j=people.size()-1;j>=0;j--)
        {
            if (people[0].first!=people[j].first)
            {
                name[i].second=people[j].second;
                people.erase(people.begin()+j);
                people.erase(people.begin());
                break;
            }
        }
    }
    for (int i=0;i<n/2;i++)
    {
        cout<<name[i].first<<" "<<name[i].second<<endl;
    }
}